home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / palis.lha / Palis / src / vpl / Com.c < prev    next >
C/C++ Source or Header  |  1992-09-02  |  2KB  |  103 lines

  1. /*
  2.     ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
  3.     presents
  4.  
  5.     PatchLibraries Utility / VIEW
  6.  
  7.     FILE:    pl.c
  8.     TASK:    control stuff
  9.  
  10.     (c)1995 by Hans Bühler, h0348kil@rz.hu-berlin.de
  11. */
  12.  
  13. #include    "plView.h"
  14.  
  15. // ---------------------------
  16. // defines
  17. // ---------------------------
  18.  
  19. // ---------------------------
  20. // datatypes
  21. // ---------------------------
  22.  
  23. // ---------------------------
  24. // proto
  25. // ---------------------------
  26.  
  27. // ---------------------------
  28. // vars
  29. // ---------------------------
  30.  
  31. static struct NewBroker    NewBroker    =
  32.     {
  33.         NB_VERSION,
  34.         PROGNAME,
  35.         PROGNAME_CX,
  36.         "See what PALIS has done for you !",
  37.         NBU_UNIQUE|NBU_NOTIFY,
  38.         COF_SHOW_HIDE,
  39.         0,        // pri
  40.         0        // port
  41.     };
  42.  
  43. CxObj        *CxMain            =    0;
  44.  
  45. // ---------------------------
  46. // funx
  47. // ---------------------------
  48.  
  49. BOOL InitCom(void)
  50. {
  51.     CxObj        *fil        =    0,
  52.                 *sen        =    0,
  53.                 *trans    =    0;
  54.     ULONG        ErrCode;
  55.  
  56.     NewBroker.nb_Pri        =    ttGetInt(&tt[ARG_CX_PRI]) % 10;
  57.     NewBroker.nb_Port        =    CxPort;
  58.  
  59.     if(!( CxMain = CxBroker(&NewBroker,&ErrCode) ))
  60.         if(ErrCode == CBERR_DUP)
  61.             return FALSE;                // be quiet
  62.  
  63.     if(CxMain)
  64.         if(fil = CxFilter(ttGetString(&tt[ARG_CX_HOTKEY])))
  65.         {
  66.             AttachCxObj(CxMain,fil);
  67.  
  68.             if(sen = CxSender(CxPort,CXE_POPUP))
  69.             {
  70.                 AttachCxObj(fil,sen);
  71.  
  72.                 if(trans = CxTranslate(0))
  73.                     AttachCxObj(fil,trans);
  74.             }
  75.         }
  76.  
  77.     if(!trans)
  78.     {
  79.         return ErrorReq(PROGNAME " error:\n"
  80.                             "Cannot crate commodities communication !",0,0,0,0);
  81.     }
  82.  
  83.     return TRUE;
  84. }
  85.  
  86. void RemCom(void)
  87. {
  88.     struct Message    *msg;
  89.  
  90.     if(CxMain)
  91.     {
  92.         Forbid();
  93.  
  94.         while(msg = GetMsg(CxPort))
  95.             ReplyMsg(msg);
  96.  
  97.         ActivateCxObj(CxMain,FALSE);
  98.         DeleteCxObjAll(CxMain);            // will rem all allocated objects !
  99.  
  100.         Permit();
  101.     }
  102. }
  103.